class Bus {
	constructor() {
		this.obj = {}
	}

	$on(name, cb) {
		// if (!this.obj[name]) {
		//   this.obj[name] = []
		// }
		// this.obj[name].push(cb)
		(this.obj[name] = []).push(cb)
	}

	$emit(name, ...args) {
		if (!this.obj[name]) return
		this.obj[name].forEach(cb => cb(...args))
	}

	$off(name) {
		this.obj[name] = []
	}
}

export default Bus
